using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_BinhLuanThem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            LoadDropDownList();
        }
        txt_ngaygui.Text = DateTime.Now.ToString("dd/MM/yyyy");
    }
   
    private void LoadDropDownList()
    {
        tbKhachHangCollection khCollection = tbKhachHangBUS.GetAll();
        ddl_khachhang.DataTextField = tbKhachHangColumns.HoTen.ToString();
        ddl_khachhang.DataValueField = tbKhachHangColumns.MaKH.ToString();
        ddl_khachhang.DataSource = khCollection;
        ddl_khachhang.DataBind();
        ddl_khachhang.Items.Insert(0, new ListItem("All", ""));

        tbSanPhamCollection spCollection = tbSanPhamBUS.GetAll();
        ddl_sanpham.DataTextField = tbSanPhamColumns.TenSP.ToString();
        ddl_sanpham.DataValueField = tbSanPhamColumns.MaSP.ToString();
        ddl_sanpham.DataSource = spCollection;
        ddl_sanpham.DataBind();
        ddl_sanpham.Items.Insert(0, new ListItem("All", ""));

    }
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
            tbBinhLuan binhluan = new tbBinhLuan();
            binhluan.KhachHang = int.Parse (ddl_khachhang.SelectedValue);
            binhluan.SanPham =int.Parse  (ddl_sanpham.SelectedValue);
            binhluan.NoiDung = txt_noidung.Text;
            binhluan.NgayGui =DateTime .Parse ( txt_ngaygui.Text);
            tbBinhLuanBUS.Insert(binhluan);
            Response.Redirect("~/Admin/BinhLuanDanhSach.aspx");
         }
        catch (Exception ex)
        {

        }
        Response.Redirect("~/Admin/BinhLuanDanhSach.aspx");

    }
}

